package algorithm.easy;

/**
 * @BelongsProject: LeetCode
 * @BelongsPackage: algorithm.easy
 * @Author: 江岸
 * @CreateTime: 2021-05-03 15:26
 * @Description:
 */
public class Reverse7 {
    //123
    public static int reverse(int x) {
        long num = x;
        boolean flag = false;
        if (num<0){
            num=-num;
            flag = true;
        }
        long res=0;
        while (num!=0){
            long a = num % 10;
            num = num/10;
            res = res * 10 + a;
        }
        if (flag) return (int) (-res<=Integer.MIN_VALUE?0:-res);
        return (int) (res>=Integer.MAX_VALUE?0:res);
    }
    public static void main(String[] args) {
        System.out.println(Integer.MAX_VALUE);
        System.out.println(  reverse( -2147483648));
    }
}
